package cn.iocoder.yudao.module.alipay.dal.mysql.alipayorder;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.alipay.dal.dataobject.elong.alipayorder.AlipayOrderDO;
import cn.iocoder.yudao.module.alipay.controller.app.alipayorder.vo.AlipayOrderExportReqVO;
import cn.iocoder.yudao.module.alipay.controller.app.alipayorder.vo.AlipayOrderPageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 支付宝订单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AlipayOrderMapper extends BaseMapperX<AlipayOrderDO> {

    default PageResult<AlipayOrderDO> selectPage(AlipayOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AlipayOrderDO>()
                .eqIfPresent(AlipayOrderDO::getTradeNo, reqVO.getTradeNo())
                .eqIfPresent(AlipayOrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(AlipayOrderDO::getBuyerId, reqVO.getBuyerId())
                .eqIfPresent(AlipayOrderDO::getAppId, reqVO.getAppId())
                .eqIfPresent(AlipayOrderDO::getCode, reqVO.getCode())
                .eqIfPresent(AlipayOrderDO::getMessage, reqVO.getMessage())
                .eqIfPresent(AlipayOrderDO::getOrderStatues, reqVO.getOrderStatues())
                .betweenIfPresent(AlipayOrderDO::getOrderTime, reqVO.getOrderTime())
                .eqIfPresent(AlipayOrderDO::getTotalAmount, reqVO.getTotalAmount())
                .eqIfPresent(AlipayOrderDO::getRetailPrise, reqVO.getRetailPrise())
                .eqIfPresent(AlipayOrderDO::getCostPrise, reqVO.getCostPrise())
                .eqIfPresent(AlipayOrderDO::getProfit, reqVO.getProfit())
                .eqIfPresent(AlipayOrderDO::getSubject, reqVO.getSubject())
                .eqIfPresent(AlipayOrderDO::getOutTradeNo, reqVO.getOutTradeNo())
                .betweenIfPresent(AlipayOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AlipayOrderDO::getId));
    }

    default List<AlipayOrderDO> selectList(AlipayOrderExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AlipayOrderDO>()
                .eqIfPresent(AlipayOrderDO::getTradeNo, reqVO.getTradeNo())
                .eqIfPresent(AlipayOrderDO::getRemark, reqVO.getRemark())
                .eqIfPresent(AlipayOrderDO::getBuyerId, reqVO.getBuyerId())
                .eqIfPresent(AlipayOrderDO::getAppId, reqVO.getAppId())
                .eqIfPresent(AlipayOrderDO::getCode, reqVO.getCode())
                .eqIfPresent(AlipayOrderDO::getMessage, reqVO.getMessage())
                .eqIfPresent(AlipayOrderDO::getOrderStatues, reqVO.getOrderStatues())
                .betweenIfPresent(AlipayOrderDO::getOrderTime, reqVO.getOrderTime())
                .eqIfPresent(AlipayOrderDO::getTotalAmount, reqVO.getTotalAmount())
                .eqIfPresent(AlipayOrderDO::getRetailPrise, reqVO.getRetailPrise())
                .eqIfPresent(AlipayOrderDO::getCostPrise, reqVO.getCostPrise())
                .eqIfPresent(AlipayOrderDO::getProfit, reqVO.getProfit())
                .eqIfPresent(AlipayOrderDO::getSubject, reqVO.getSubject())
                .eqIfPresent(AlipayOrderDO::getOutTradeNo, reqVO.getOutTradeNo())
                .betweenIfPresent(AlipayOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AlipayOrderDO::getId));
    }

}
